//package com.msc.config;
//
//
//import com.alibaba.druid.pool.DruidDataSource;
//import org.apache.ibatis.plugin.Interceptor;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.SqlSessionFactoryBean;
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//
//import javax.sql.DataSource;
//
///**
// * @author 骑蜗牛的羊
// * @date 2023/4/12 21:34
// * <p></p>
// */
////@Configuration
////@MapperScan(basePackages = InfoDBConfig.PACKAGE, sqlSessionFactoryRef = "infoSqlSessionFactory")
//public class InfoDBConfig {
////    @Autowired
////    MyBatisExtendsInterceptor myBatisExtendsInterceptor;
//
//    static final String PACKAGE = "com.msc.mapper";
//    static final String MAPPER_LOCATION = "classpath*:/mapper/**Mapper.xml";
//
//    @Value("${spring.datasource.url}")
//    private String url;
//
//    @Value("${spring.datasource.username}")
//    private String username;
//
//    @Value("${spring.datasource.password}")
//    private String password;
//
////    @Value("${infodb.datasource.maxActive}")
//    private int maxActive=100;
//
////    @Value("${infodb.datasource.testWhileIdle}")
//    private boolean testWhileIdle=false;
//
//    @Value("${spring.datasource.driver-class-name}")
//    private String driverClassName;
//
//    @Bean(name = "infodbDataSource")
//    public DataSource infodbDataSource() {
//        DruidDataSource crDataSource = new DruidDataSource();
//        crDataSource.setUrl(url);
//        crDataSource.setUsername(username);
//        crDataSource.setPassword(password);
//        crDataSource.setMaxActive(maxActive);
//        crDataSource.setTestWhileIdle(testWhileIdle);
//
//        crDataSource.setDriverClassName(driverClassName);
//        return crDataSource;
//    }
//
//    @Bean(name = "infodbTransactionManager")
//    public DataSourceTransactionManager infodbTransactionManager() {
//        return new DataSourceTransactionManager(infodbDataSource());
//    }
//
//    @Bean(name = "infoSqlSessionFactory")
//    public SqlSessionFactory infodbSqlSessionFactory(@Qualifier("infodbDataSource") DataSource infodbDataSource)
//            throws Exception {
//        final SqlSessionFactoryBean sessionFactoryBean = new SqlSessionFactoryBean();
//        sessionFactoryBean.setDataSource(infodbDataSource);
//        sessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(InfoDBConfig.MAPPER_LOCATION));
//        // 增加sql执行的拦截器
////        Interceptor[] plugins = new Interceptor[]{ myBatisExtendsInterceptor };
////        sessionFactoryBean.setPlugins(plugins);
//        return sessionFactoryBean.getObject();
//    }
//}